<?php
namespace App\Admin\Models;
use Common\BaseModel;
class AdminUserToken extends BaseModel
{
    protected $res;
    protected $redis_key="admin_";
    public function getSource()
    {
        return "f_admin_token";
    }
    public function initialize()
    {
        parent::initialize();
    }

    public function find_by_id($id){
        return $this->findById($id);
    }



    /**
     * @func 根据用户id获取用户信息
     */
    public function find_by_firstAdminId($user_id){
        $user_info = $this->findFirstByAdminId($user_id);
        if(!$user_info){
            return false;
        }else{
            return $user_info->toarray();
        }
    }



    /**
     * @func 根据用户token获取用户信息
     */
    public function find_by_firstToken($token){
        $user_info = $this->findFirstByToken($token);
        if(!$user_info){
            return false;
        }else{
            return $user_info->toarray();
        }
    }


    /**
     * @func 更新/插入数据
     * @param $data要更新或者要插入的数据
     * @return boolean 插入成功的结果
     */
    public function save_user($data){
        $data['flushtime'] = date('Y-m-d H:i:s',time());
        $result = $this->save($data);
        return $result;
    }
}
